import { defineStore } from "pinia";
import { ref } from "vue";

export const useConsultStore=defineStore('consult',()=>{
	
	const consult=ref({})
	//保存病情描述数据
	const setConsult=(value)=>{
		consult.value.illnessDesc=value.illnessDesc
		consult.value.illnessTime=value.illnessTime
		consult.value.consultFlag=value.consultFlag
		consult.value.pictures=value.pictures
	}
	//清空病情描述数据
	const clearConsult=()=>{
		consult.value={}
	}
	
	//保存问诊类型
	const setType=(value)=>consult.value.type=value
	//保存选择科室
	const setIllnessType=(value)=>consult.value.illnessType=value
	//保存科室id
  const setDepId=(value)=>consult.value.depId=value
	
	//保存患者id
	const setPatientId=(value)=>consult.value.patientId=value
	return {
		consult,
		setConsult,
		clearConsult,
		setType,
		setIllnessType,
		setDepId,
		setPatientId
	}
},
{
	//持久化配置
	persist:{
		storage:{
			setItem:(key,value)=>{
				uni.setStorageSync(key,value)
			},
			getItem:(key)=>{
				return uni.getStorageSync(key)
			}
		}
	}
}
)